package cn.donting.jme.edit.ui.scenetree.meum;

import cn.donting.jme.edit.EditorState;
import cn.donting.jme.edit.ui.scenetree.ClipBoard;
import cn.donting.jme.edit.ui.scenetree.SceneTreeNodeView;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import javafx.event.ActionEvent;
import javafx.scene.input.MouseEvent;

public class DeleteMenuItem extends AbsTreeMenuItem {
    public DeleteMenuItem() {
        super("删除");
    }

    @Override
    public boolean isAvailable(ClipBoard clipBoard) {
        SceneTreeNodeView instance = SceneTreeNodeView.getInstance();
        Spatial selectSpatial = instance.getSelectSpatial();
        Node rootNode = EditorState.getJmeEditSceneApp().getRootNode();
        if (selectSpatial==null||selectSpatial.getParent() == rootNode) {
            return false;
        }
        return true;
    }

    @Override
    public void action(ClipBoard clipBoard) {
        clipBoard.getSceneTreeNodeView().deleteSelectNode();
    }
}
